package Servlet;

import pojo.Brand;
import service.BrandService;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "toUpdateServlet", value = "/toupdate")
public class toUpdateServlet extends HttpServlet {
   private BrandService brandService = new BrandService();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //1
        String  id  =request.getParameter("id");
        Integer idd = Integer.valueOf(id);
        //2
        Brand brand =  brandService.selectByid(idd);
        //3
        request.setAttribute("brand",brand);
        //4
        request.getRequestDispatcher("/updateBrand.jsp").forward(request,response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }
}
